package com.example.nettydemo.controller;

import com.example.nettydemo.game.Room;
import com.example.nettydemo.server.NettyChannelHandlerPool;
import com.example.nettydemo.util.MockData;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author WZW
 * @date 2020/5/11
 */
@RestController
public class DebugController {

    @GetMapping("/debug")
    public Object debug() {
        Map<String, Object> map = new HashMap<>();
        Map<String, Room> roomMap = NettyChannelHandlerPool.getRoomMap();
        Map<String, Set<String>> roomIdGuidSetMap = NettyChannelHandlerPool.getRoomIdGuidSetMap();
        map.put("room_map", roomMap);
        map.put("room_id_guid_set_map", roomIdGuidSetMap);
        List<String> userList = new ArrayList<>();
        MockData.USER_LIST.forEach(user -> userList.add(user.toString()));
        map.put("user_list", userList);
        return map;
    }

}
